package viewbuilder.java

import viewbuilder.HtmlBuilder
/**
 * 
 */
class GroovyTable {

    def builder

    GroovyTable(builder) {
        this.builder = builder
    }

    def renderCustomerUserTable(customer, customerUsers) {

        builder.table(summary: "Table Summary",
            id: "userTable") {
            tableHead(builder, customer)
            tfoot {
                tr {
                    td('colspan': "100%", "Table Summary")
                }
            }
            tableBody(builder, customer, customerUsers)
        }
        
    }

    def tableHead(builder, customer) {
        builder.thead {
            tr {
                th("Status")
                th(id: "username", scope: "col", "Username")
                th(id: "firstName", scope: "col", "First Name")
                th(id: "lastName", scope: "col", "Last Name")
            }
        }

    }

    def tableBody(builder, customer, customerUsers) {
        builder.tbody {

            customerUsers.each {user ->

                tr(id: user.id, 'class': 'makeValidate ') {

                    td('class': "status sortable-text") {
                        span('class': "sortdatum", "true")
                    }

                    td('class': 'sortable-text sortField-username', user.username)
                    td('class': 'hidehandheld sortable-text sortField-firstName', user.firstName)
                    td('class': 'hidehandheld sortable-text sortField-lastName', user.lastName)
                }
            }
        }
    }

}